package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.SecurityActivity;
import com.ruoyi.system.mapper.SecurityActivityMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SecurityReportMapper;
import com.ruoyi.system.domain.SecurityReport;
import com.ruoyi.system.service.ISecurityReportService;

/**
 * 安防上报
Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-07-22
 */
@Service
public class SecurityReportServiceImpl implements ISecurityReportService 
{
    @Autowired
    private SecurityReportMapper securityReportMapper;
    @Autowired
    private SecurityActivityMapper securityActivityMapper;

    /**
     * 查询安防上报

     * 
     * @param srId 安防上报
ID
     * @return 安防上报

     */
    @Override
    public SecurityReport selectSecurityReportById(Long srId)
    {
        SecurityReport securityReport = securityReportMapper.selectSecurityReportById(srId);
        SecurityActivity securityActivity= new SecurityActivity();
        securityActivity.setSrId(securityReport.getSrId());
        securityReport.setSecurityActivities(securityActivityMapper.selectSecurityActivityList(securityActivity));
        return securityReport;
    }

    /**
     * 查询安防上报
列表
     * 
     * @param securityReport 安防上报

     * @return 安防上报

     */
    @Override
    public List<SecurityReport> selectSecurityReportList(SecurityReport securityReport)
    {
        List<SecurityReport> securityReports = securityReportMapper.selectSecurityReportList(securityReport);
        for (int i = 0; i <securityReports.size() ; i++) {
            SecurityActivity securityActivity= new SecurityActivity();
            securityActivity.setSrId(securityReports.get(i).getSrId());
            securityReports.get(i).setSecurityActivities(securityActivityMapper.selectSecurityActivityList(securityActivity));
        }
        return securityReports;
    }

    /**
     * 新增安防上报

     * 
     * @param securityReport 安防上报

     * @return 结果
     */
    @Override
    public int insertSecurityReport(SecurityReport securityReport)
    {securityReport.setSrCreatetime(DateUtils.getNowDate());
        return securityReportMapper.insertSecurityReport(securityReport);
    }

    /**
     * 修改安防上报

     * 
     * @param securityReport 安防上报

     * @return 结果
     */
    @Override
    public int updateSecurityReport(SecurityReport securityReport)
    {
        return securityReportMapper.updateSecurityReport(securityReport);
    }

    /**
     * 批量删除安防上报

     * 
     * @param srIds 需要删除的安防上报
ID
     * @return 结果
     */
    @Override
    public int deleteSecurityReportByIds(Long[] srIds)
    {
        return securityReportMapper.deleteSecurityReportByIds(srIds);
    }

    /**
     * 删除安防上报
信息
     * 
     * @param srId 安防上报
ID
     * @return 结果
     */
    @Override
    public int deleteSecurityReportById(Long srId)
    {
        return securityReportMapper.deleteSecurityReportById(srId);
    }
}
